package com.service.impl;

import com.entity.PageBean;
import com.entity.PurOrder;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.PurOrderDetailMapper;
import com.mapper.PurOrderMapper;
import com.service.PurOrderDetailService;
import com.service.PurOrderService;
import com.vo.PurOrderDetailVO;
import com.vo.PurOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class PurOrderDetailServiceImpl implements PurOrderDetailService {
    @Autowired
    private PurOrderDetailMapper purOrderDetailMapper;

    @Override
    public PageBean<PurOrder> getOrderDetailList(Integer pageIndex, Integer pageSize, PurOrderDetailVO purOrderDetailVO) {
        PageHelper.startPage(pageIndex, pageSize);
        List<PurOrder> list= purOrderDetailMapper.selectOrderDetailList(purOrderDetailVO);
        PageInfo<PurOrder> pageInfo = new PageInfo<>(list);
        PageBean<PurOrder> pageBean = new PageBean<>(
                pageIndex,//第几页
                pageSize,//每页显示的条数
                pageInfo.getPages(),//总页数
                (int)pageInfo.getTotal(),//数据总条数
                pageInfo.getList()//当前页的数据集合
        );
        return pageBean;
    }

    @Override
    public List<PurOrder> findtAll() {
        return purOrderDetailMapper.selectAll();
    }

    @Override
    public Integer getSumAmount(PurOrder purOrder) {
        return purOrderDetailMapper.getSumAmount(purOrder);
    }

    @Override
    public BigDecimal getSumMtsum(PurOrder purOrder) {
        return purOrderDetailMapper.getSumMtsum(purOrder);
    }


}
